package exception01;

import java.io.IOException;
import java.util.zip.DataFormatException;

public class ExceptionDemo09 {
    public static void main(String[] args) {
        try {
            //method(0);  // method(0)抛出new IOException(),被catch(IOException e) 接收
                             // 相当于 IOException e = new IOException() ; 然后解决异常

            method(2); //  method(2)抛出new Exception(),由于catch(IOException e)无法接收 catch(Exception e)
                          // 也就无法处理，因此new Exception()会找catch(Exception e) 处理

        } catch (IOException e){
            System.out.println("捕获了IOException");
        }catch (Exception e ){
            System.out.println("捕获了Exception");
        }
    }
    public static void method(int a) throws IOException,Exception{
        if(a==0){
            throw new IOException();
        }
        if(a==2){
            throw new Exception();
        }
    }
}
